// 订单模型
const { Orders } = require('../../../models/order');
// 用户模型
const { Goods } = require('../../../models/good');

// 统一数据返回类
const { DataReturn } = require('../../../common/returnclass');

module.exports = async (req, res) => {
	let { user_id, pagenum } = req.query;
	console.log(req.query);
	let pagesize = 10;
	pagenum = parseInt(pagenum);
	
	let orders = await Orders.find({ order_belong: user_id }).skip(pagesize*(pagenum-1)).limit(pagesize);
	
	if (!orders) return DataReturn.getData(res,400, orders,'暂无数据');
	DataReturn.getData(res,200, {data:orders,total: await Orders.find({ order_belong: user_id }).countDocuments() },'获取订单列表成功');


}